package com.rd.student.dashuju.sunwenzhuo.Test3;

public class TenThread implements Runnable {
    int AllNum = 0;
    int num = 0;

    @Override
    public void run() {
        for (int i = 1; i <= 100; i++) {
            AllNum = num + i;
            if (i % 10 == 0) {
//                AllNum = 0;
                Thread.yield();
            }

        }
        System.out.println(Thread.currentThread().getName()+" "+AllNum);
    }

    public static void main(String[] args) throws InterruptedException {

        TenThread t = new TenThread();
        Thread t1 = new Thread(t);
        Thread t2 = new Thread(t);
        Thread t3 = new Thread(t);
        Thread t4 = new Thread(t);
        Thread t5 = new Thread(t);
        Thread t6 = new Thread(t);
        Thread t7 = new Thread(t);
        Thread t8 = new Thread(t);
        Thread t9 = new Thread(t);
        Thread t10 = new Thread(t);

        t1.start();

        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t3.join();
        t4.start();
        t4.join();
        t5.start();
        t5.join();
        t6.start();
        t6.join();
        t7.start();
        t7.join();
        t8.start();
        t8.join();
        t9.start();
        t9.join();
        t10.start();
        t10.join();



        int c = 0;
        for (int i = 1; i <= 100; i++) {
            c += i;
        }
        System.out.println("总和" + c);




    }
}